package com.ruoyi.web.controller.laiqianba.channel;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.ChannelUnionResultInfo;
import com.ruoyi.channel.service.IChannelUnionResultInfoService;
import com.ruoyi.web.wrapper.ChannelUnionResultInfoWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 渠道联登结果信息Controller
 * 
 * @author ruoyi
 * @date 2023-12-15
 */
@RestController
@RequestMapping("/channel/result")
public class ChannelUnionResultInfoController extends BaseController
{
    @Autowired
    private IChannelUnionResultInfoService channelUnionResultInfoService;

    /**
     * 查询渠道联登结果信息列表
     */
    @PreAuthorize("@ss.hasPermi('channel:result:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChannelUnionResultInfo channelUnionResultInfo)
    {
        startPage();
        List<Map<String, Object>> list = channelUnionResultInfoService.selectChannelUnionResultInfoMapList(channelUnionResultInfo);
        list = new ChannelUnionResultInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出渠道联登结果信息列表
     */
    @PreAuthorize("@ss.hasPermi('channel:result:export')")
    @Log(title = "渠道联登结果信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChannelUnionResultInfo channelUnionResultInfo)
    {
        List<ChannelUnionResultInfo> list = channelUnionResultInfoService.selectChannelUnionResultInfoList(channelUnionResultInfo);
        ExcelUtil<ChannelUnionResultInfo> util = new ExcelUtil<ChannelUnionResultInfo>(ChannelUnionResultInfo.class);
        util.exportExcel(response, list, "渠道联登结果信息数据");
    }

    /**
     * 获取渠道联登结果信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('channel:result:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(channelUnionResultInfoService.selectChannelUnionResultInfoById(id));
    }

    /**
     * 新增渠道联登结果信息
     */
    @PreAuthorize("@ss.hasPermi('channel:result:add')")
    @Log(title = "渠道联登结果信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChannelUnionResultInfo channelUnionResultInfo)
    {
        return toAjax(channelUnionResultInfoService.insertChannelUnionResultInfo(channelUnionResultInfo));
    }

    /**
     * 修改渠道联登结果信息
     */
    @PreAuthorize("@ss.hasPermi('channel:result:edit')")
    @Log(title = "渠道联登结果信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChannelUnionResultInfo channelUnionResultInfo)
    {
        return toAjax(channelUnionResultInfoService.updateChannelUnionResultInfo(channelUnionResultInfo));
    }

    /**
     * 删除渠道联登结果信息
     */
    @PreAuthorize("@ss.hasPermi('channel:result:remove')")
    @Log(title = "渠道联登结果信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(channelUnionResultInfoService.deleteChannelUnionResultInfoByIds(ids));
    }
}
